Method and system for measuring lens distortion

ABSTRACT

A method for measuring lens distortion, comprising: providing a test card having a dot matrix pattern of K×N dots, wherein the K and the N are both natural numbers ( 110 ); obtaining a distorted image of the test card after being distorted by a lens ( 120 ); establishing a planar coordinate system for the distorted image by using a dot at an upper left corner of the distorted image as a coordinate origin, a rightward direction from the origin as a positive direction of axis X, and a downward direction from the origin as a positive direction of axis Y ( 130 ); positioning a center dot of the distorted image and all non-center dots by scanning and searching, and determining coordinate values of the center dot and all the non-center dots in the planar coordinate system ( 140 ); and calculating a distortion amount of the distorted image by using the coordinate values of the center dot and all the non-center dots according to a distortion amount calculation equation for the distorted image, thereby obtaining a distortion amount of the lens ( 150 ). Also disclosed is a system for measuring lens distortion. The measurement method and system accelerates the image processing speed and improves the lens distortion measurement accuracy.

TECHNICAL FIELD

The present disclosure relates to the technical field of imageprocessing, and particularly, to a method and system for measuring lensdistortion.

BACKGROUND

With the improvement of scientific and technological level, the consumerelectronics enter people's lives at a rapid pace, and head-mounteddisplay products attract the attention of people by virtue of thegorgeous appearances and the advanced functions. Head-mounted displayproducts apply visual technology perfectly to display images with an LCDscreen of a high resolution, and amplify the images with a lens so thatthe user can view clear images. In addition, the images are processedwith 3D technology so that the user feels a visual impact from 3Dtechnology. However, the images are distorted while being amplified bythe lens. The distortion is a geometric distortion of imaging, and is ascreen twisted deformation phenomenon caused by the differentmagnification powers to an image in different areas of the focal plane.The degree of the deformation progressively increases from the screencenter to the screen edges, and is mainly obvious at the screen edges.Thus the distortion amount should be measured to recover the distortedimage into the normal image through image processing technology. Methodsfor measuring lens distortion in the prior art have slow calculationspeeds and low measurement accuracies, and a large error will be causedafter the recovering into the normal image, which cannot satisfyrequirement on image processing.

SUMMARY

The present disclosure provides a method and system for measuring lensdistortion, so as to solve the problem that the existing method formeasuring lens distortion has a slow calculation speed and a lowmeasurement accuracy.

In order to achieve the above objective, the technical solutions of thepresent disclosure are realized as follows:

The present disclosure provides a method for measuring lens distortion,comprising:

providing a test card having a dot matrix pattern of K×N dots, whereinthe K and the N are both natural numbers, and the K is equal or unequalto the N;

obtaining a distorted image of the test card after being distorted by alens;

establishing a planar coordinate system for the distorted image by usinga dot at an upper left corner of the distorted image as a coordinateorigin, a rightward direction from the origin as a positive direction ofaxis X, and a downward direction from the origin as a positive directionof axis Y;

positioning a center dot and all non-center dots of the distorted imageby scanning and searching, and determining coordinate values of thecenter dot and all the non-center dots in the planar coordinate system;and

calculating a distortion amount of the distorted image by using thecoordinate values of the center dot and all the non-center dots, therebyobtaining a distortion amount of the lens.

Preferably, on the test card, the center dot has a radius larger thanthat of any of the non-center dots.

Preferably, the positioning a center dot and all non-center dots of thedistorted image by scanning and searching comprises:

setting a square searching area centered at a coordinate of a center ofthe distorted image, a half of a side length of the square searchingarea being larger than or equal to two times of a radius of the centerdot;

setting a square scanning area centered at a dot at an upper left cornerof the square searching area, a half of whose side length is equal tothe radius of the center dot; starting from a center of the scanningarea to scan the scanning area, and calculating an average value of allpixel points in the scanning area; and

in the searching area, sequently moving the center of the scanning areauntil the searching area is completely scanned; comparing the averagevalues of the pixel points obtained in the scanning area each time withone another, and determining a center of a scanning area where a minimumaverage value or a maximum average value among all the average values ofthe pixel points is located as a center of the center dot; anddetermining in turn a coordinate value of the center of the center dot,and determining the coordinate value of the center of the center dot asthe coordinate value of the center dot; and

by the similar method, determining coordinate values of all thenon-center dots.

Preferably, the sequently moving the center of the scanning areacomprises:

in the searching area, moving the center of the scanning area from topto bottom and from left to right until the searching area is completelyscanned; and

the by the similar method, determining coordinate values of all thenon-center dots comprises:

moving the square searching area leftwards at a specific step lengthwith reference to the center of the center dot, to position all thenon-center dots on the left and in the same row with the center dot, anddetermine the coordinate values of the non-center dots;

moving the square searching area rightwards at a specific step lengthwith reference to the center of the center dot, to position all thenon-center dots on the right and in the same row with the center dot,and determine the coordinate values of the non-center dots;

moving the square searching area downwards at a specific step lengthwith reference to the center of the center dot, to position all thenon-center dots in a row next to the row where the center dot islocated, and determine the coordinate values of the non-center dots; and

moving the square searching area upwards at a specific step length withreference to the center of the center dot, to position all thenon-center dots in a row previous to the row where center dot islocated, and determine the coordinate values of the non-center dots.

Preferably, the method further comprises: defining in a cache atwo-dimensional array with a length at least containing all the dots,and storing coordinate information of the center dot into a center arrayof the two-dimensional array;

sequently storing all the positioned dots into the two-dimensional arrayaccording to relative physical positions on the distorted image, toestablish index relationships of the center dot and all the non-centerdots with the two-dimensional array.

Preferably, the calculating a distortion amount of the distorted imageby using the coordinate values of the center dot and all the non-centerdots comprises:

finding four dots A1, A2, A3 and A4 respectively located at an edge ofthe distorted image according to the index relationships of the centerdot and all the non-center dots with the two-dimensional array, the fourdots A1, A2, A3 and A4 simultaneously satisfying a condition that everytwo of the four dots A1, A2, A3 and A4 are located in a same referenceline;

finding middle dots of the same reference lines where every two of thefour dots A1, A2, A3 and A4 are located, according to indexrelationships of the center dot with the four dots A1, A2, A3 and A4 andall the non-center dots in the same reference lines where every two ofthe four dots A1, A2, A3 and A4 are located, wherein a middle dot of thereference line where the dots A1 and A2 are located is denoted as B1, amiddle dot of the reference line where the dots A2 and A3 are located isdenoted as B2, a middle dot of the reference line where the dots A3 andA4 are located is denoted as B3, and a middle dot of the reference linewhere the dots A1 and A4 are located is denoted as B4, the middle dotsB1, B2, B3 and B4 simultaneously satisfying the conditions that,

the dot B1, the center dot and the dot B3 are located in a samereference line;

the dot B2, the center dot and the dot B4 are located in a samereference line;

index differences of the dots A1 and A2 relative to the dot B1 are equaland denoted as m, index differences of the dots A3 and A4 relative tothe dot B3 are equal and denoted as n, and m=n; and

index differences of the dots A1 and A4 relative to the dot B4 are equaland denoted as u, index differences of the dots A2 and A3 relative tothe dot B2 are equal and denoted as v, and v=u.

Preferably, calculating a distortion amount of the distorted image byusing the coordinate values of the center dot and all the non-centerdots further comprises:

calculating a distortion amount of the distorted image in a verticaldirection according to the following formula:

Vertical=100%*(DisA1A4+DisA2A3)/(2*DisB1B3)

wherein, DisA1A4 denotes a distance between the dots A1 and A4, DisA2A3denotes a distance between the dots A2 and A3, DisB1B3 denotes adistance between the dots B1 and B3, and Vertical denotes the distortionamount of the distorted image in the vertical direction; and

calculating a distortion amount of the distorted image in a horizontaldirection according to the following formula:

Horizontal=100%*(DisA1A2+DisA3A4)/(2*DisB2B4)

wherein, DisA1A2 denotes a distance between the dots A1 and A2, DisA3A4denotes a distance between the dots A3 and A4, DisB2B4 denotes adistance between the dots B2 and B4, and Horizontal denotes thedistortion amount of the distorted image in the horizontal direction.

Preferably, the obtaining a distorted image of the test card after beingdistorted by a lens comprises:

providing an industrial camera of high definition, and shooting with theindustrial camera the test card through the lens when a center of theindustrial camera, a center of the lens, and a center of the test cardcoincide, so as to obtain the distorted image.

Preferably, when the center dot and the non-center dots are black dots,determining the center of the scanning area where the minimum averagevalue among all the average values of the pixel points is located as acenter of the center black dot, and determining the coordinate value ofthe center of the center black dot.

The present disclosure further provides a system for measuring lensdistortion, wherein the above method is applied to measure the lensdistortion, the system comprising:

a test card having a dot matrix pattern of K×N dots;

an imaging device configured to obtain a distorted image of the testcard after being distorted by a lens; and

an image processing device configured to establish a planar coordinatesystem for the distorted image by using a dot at an upper left corner ofthe distorted image as a coordinate origin, a rightward direction fromthe origin as a positive direction of axis X, and a downward directionfrom the origin as a positive direction of axis Y; position a center dotand all non-center dots of the distorted image by scanning andsearching, and determine coordinate values of the center dot and all thenon-center dots in the planar coordinate system; and calculate adistortion amount of the distorted image by using the coordinate valuesof the center dot and all the non-center dots, thereby obtaining adistortion amount of the lens.

The method and system for measuring lens distortion provided by thepresent disclosure can quickly and accurately position all the dots onthe test card, and the actual error range reaches the sub pixel level,thereby achieving the purpose of rapidly calculating the distortionamount of the distorted image and really reflecting the distortion ofthe lens.

Other features and advantages of the application will be elaborated inthe subsequent description, and they are partially apparent from thedescription or understood by implementing the application. Theobjectives and other advantages of the application can be realized andobtained by the structures particularly pointed out in the description,claims and drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

The drawings are provided for a further understanding of the presentdisclosure, and constitute part of the specification. The drawings areused together with the embodiments of the present disclosure to explainthe present disclosure, rather than making any limitation to the presentdisclosure. In the figures,

FIG. 1 is a flow diagram of a method for measuring lens distortionprovided by an embodiment of the present disclosure;

FIG. 2 is a schematic diagram of a test card provided by an embodimentof the present disclosure;

FIG. 3 is a schematic diagram for acquiring a distorted image providedby an embodiment of the present disclosure;

FIG. 4 is a schematic diagram of a distorted image of a test card afterbeing distorted by a lens provided by an embodiment of the presentdisclosure;

FIG. 5 is a model diagram for positioning black dots in a distortedimage provided by an embodiment of the present disclosure;

FIG. 6 is a physical diagram of all positioned black dots provided by anembodiment of the present disclosure;

FIG. 7 is a schematic diagram of black dot coordinate caches provided byan embodiment of the present disclosure; and

FIG. 8 is a reference diagram for calculating a distortion amount of adistorted image provided by an embodiment of the present disclosure.

DETAILED DESCRIPTION

In order that the objectives, technical solutions and advantages of thepresent disclosure are clearer, the embodiments of the presentdisclosure will be further described in details as follows withreference to the drawings.

The core idea of the present disclosure is to use a new distorted imagetest card provided with black dots which form a dot matrix pattern,perform coordinate positioning based on the test card to quicklyrecognize the coordinates of all the black dots of the distorted image,and calculate the distortion amount of the distorted image according tothe coordinates of all the black dots. The measurement method of thepresent disclosure can quickly find the black dots on the test card,accelerate the processing speed of the distortion amount measurement,and improve the measurement accuracy.

FIG. 1 is a flow diagram of a method for measuring lens distortionprovided by an embodiment of the present disclosure. Referring to FIG.1, the method comprises:

step S110: providing a test card having a dot matrix pattern of K×Ndots, wherein the K and the N are both natural numbers, and the K isequal or unequal to the N;

step S120: obtaining a distorted image of the test card after beingdistorted by a lens;

step S130: establishing a planar coordinate system for the distortedimage by using a dot at an upper left corner of the distorted image as acoordinate origin, a rightward direction from the origin as a positivedirection of axis X, and a downward direction from the origin as apositive direction of axis Y;

step S140: positioning a center dot and all non-center dots of thedistorted image by scanning and searching, and determining coordinatevalues of the center dot and all the non-center dots in the planarcoordinate system;

step S150: calculating a distortion amount of the distorted image byusing the coordinate values of the center dot and all the non-centerdots, thereby obtaining a distortion amount of the lens.

By constructing the planar coordinate system of the distorted image, allthe dots in the distorted image are quickly recognized, and thecoordinate values of all the dots on the distorted image are calculated.The measurement method requires a small calculation amount, therebyincreasing the distorted image measurement speed. Meanwhile, the testcard using the dot matrix pattern of K×N dots ensures the improvement ofthe measurement accuracy.

FIG. 2 is a schematic diagram of a test card provided by an embodimentof the present disclosure. Referring to FIG. 2, which locally displaysthe test card used in this embodiment: a square matrix of 21 rows and 21columns of black dots, wherein 1 denotes a center black dot of thesquare matrix, and the center black dot has a radius larger than that ofany of the non-center black dots, so as to be aligned with the cameracenter when the distorted image is shot. In addition, the larger radiusof the center black dot facilities the recognition of the center dotwhen calculation processing is performed by using the image processingtechnology. It can be understood that FIG. 2 only illustrates a middlepart of the distorted image of the test card shot by the lens taken inthis embodiment. Since the lens causes the distortion of the test card,the edge portion of the distorted image has a nearly circular shape,while the middle part is approximately a matrix arrangement.

When the head-mounted display product and other similar smart displayproduct display an image with an LCD screen of a high resolution, amagnification shall be made with a lens so that the user can view aclear image. But the image will be distorted when being magnified by thelens. The method of the present disclosure is to measure a distortionamount of a distorted image, and the distorted image should be acquiredbefore the measurement. FIG. 3 is a schematic diagram for acquiring adistorted image provided by an embodiment of the present disclosure.Referring to FIG. 3, a high-pixel (e.g., 10 megapixels) industrialcamera 31 shoots a test card placed on an LCD screen 33 of thehead-mounted display product through a lens 32, and makes the center ofthe picture of the test card coincide with the center of the camera 31and the center of the lens 32. In that case, the shot distorted imagecan accurately indicate the distortion amount of the image caused by thelens.

FIG. 4 is a schematic diagram of a distorted image of a test card afterbeing distorted by a lens provided by an embodiment of the presentdisclosure. FIG. 4 can best reflect the proper area for calculating lensdistortion, wherein the dots on the four corners at the edge are closeto the image edge so far as possible, and every two dots are located ina same reference line outermost and most complete at the edge; generallythey form an F×F dot matrix area, and F is an odd number. Referring toFIG. 4, the test card is pillow-distorted while being magnified by thelens, thus the positions of the black dots on the test card are offsetby the distortion, and the offset position of each black dot isdifferent from each other, wherein the black dots at the edge positionson the periphery of the distorted image have the largest distortiondegree. The present disclosure determines coordinate values of all theblack dots on the distorted image by means of coordinate positioning. Onthe distorted image of the test card after being distorted by the lens,the relative physical positions of the center dot and other non-centerdots are unchanged, and the specific coordinate values may be changed.The coordinates of all the black dots are positioned by using thecoordinate positioning technology. Since the relative physical positionsof the black dots are unchanged and the actual coordinate values arechanged, the distortion amount of the distorted image is obtained byusing the changed coordinate values of all the black dots and adistortion amount calculation formula, thereby obtaining a distortionamount of the lens, so as to adjust the distorted image to reduce theerror when being recovered into the normal image.

Next, the positioning of all the black dots of the distorted image willbe described with reference to FIGS. 5 and 6. FIG. 5 is a model diagramfor positioning black dots in a distorted image provided by anembodiment of the present disclosure. FIG. 6 is a physical diagram ofall positioned black dots provided by an embodiment of the presentdisclosure.

The method of positioning a center dot and all non-center dots of thedistorted image by scanning and searching is specifically to set asquare searching area centered at a coordinate of the center of thedistorted image, a half of a side length of the square searching areabeing larger than or equal to two times of a radius of the center dot;set a square scanning area centered at a dot at the upper left corner ofthe square searching area, a half of whose side length is equal to theradius of the center dot; start from a center of the scanning area toscan the image in the scanning area and calculate an average value ofall pixel points of the images in the scanning area; in the searchingarea, sequently move the center of the scanning area until the searchingarea is completely scanned; compare the average values of the pixelpoints obtained in the scanning area each time with one another, anddetermine a center of a scanning area where a minimum average value or amaximum average value among all the average values of the pixel pointsis located as a center of the center dot; determine the coordinate valueof the center of the center dot, and determine the coordinate value ofthe center of the center dot as the coordinate value of the center dot;and by the similar method, determine coordinate values of all thenon-center dots.

Referring to FIG. 5, in this embodiment, the center dot and thenon-center dots on the test card are black dots. In the black area wherethe center black dot shown in FIG. 5 is located, a square searching areais defined with the radius 51 equal to or larger than two times of theradius 52 of the black dot, and a square scanning area centered at a dotat the upper left corner of the searching area is defined with theradius 53 equal to the radius of the black dot. In the searching areawith the larger radius, the center of the scanning area is sequentlymoved for scanning from top to bottom and from left to right; theaverage value of all the pixel points in the scanning area is recordedeach time a scanning is carried out, until the searching area iscompletely scanned; and the average value of the pixel points obtainedin the scanning area each time is compared with one another, the centerof the scanning area where the minimum average value is located isdetermined as the center of the center black dot to complete thepositioning of the center black dot, and the coordinate value of thecenter black dot is calculated and saved. It can be understood that whenthe method of the present disclosure is applied, the color of the dotson the test card is not limited to black. Thus, when the dots on thetest card are to be positioned, the center of a scanning area where theaverage value is the minimum or the maximum shall be selected as thecenter of the center dot, according to the pixel values of the specificcolor of the dots. In this embodiment, the dots on the test card areblack, and thus the pixel value decreases when the scanning areacontains more black parts, and the pixel value of absolute black is 0.In other embodiments of the present disclosure, the ground color of thetest card may be other colors. In the event that the center dot and thenon-center dots are for example white, when a positioning is to be madewith the scanning areas, the center of the scanning area where a maximumaverage value (the pixel value of white color is 255) among the averagevalues of the pixel points of the scanning areas is located will bepositioned as the center of the center dot.

All the non-center black dots are positioned by a method similar to thatof positioning the center black dot, comprising: moving the squaresearching area leftwards at a specific step length with reference to thecenter of the center black dot, to position all the non-center blackdots on the left and in the same row with the center black dot, anddetermining the coordinate values of the non-center black dots; movingthe square searching area rightwards at a specific step length withreference to the center of the center black dot to position all thenon-center black dots on the right and in the same row with the centerblack dot, and determining the coordinate values of the non-center blackdots; moving the square searching area downwards at a specific steplength with reference to the center of the center black dot, to positionall the non-center black dots in the row next to the row where thecenter black dot is located, and determining the coordinate values ofthe non-center black dots; and moving the square searching area upwardsat a specific step length with reference to the center of the centerblack dot, to position all the non-center black dots in the row previousto the row where the center black dot is located, and determining thecoordinate values of the non-center black dots.

When the non-center black dot is positioned, the radius of the selectedsquare searching area is two times of that of the non-center black dotor more. When the searching area is moved, the specific step length isthe distance between every two black dot centers on the distorted image,and it is a preset empirical value, wherein a moving each time by thespecific step length can avoid unnecessary scanning, thereby improvingthe scanning speed and efficiency of the scanning area.

FIG. 6 is a physical diagram of all positioned black dots provided by anembodiment of the present disclosure. Referring to FIG. 6, after beingpositioned, the center black dot and all the non-center black dots aremarked with circles. Through the above steps, the coordinate values ofthe center black dot and the non-center black dots are determined andsaved.

As for saving the coordinate values, an embodiment of the presentdisclosure stores the coordinate values in the manner of atwo-dimensional array. FIG. 7 is a schematic diagram of black dotcoordinate caches provided by an embodiment of the present disclosure.Referring to FIG. 7, several dots on the distorted image are exemplarilyselected, and the coordinate values of the selected dots are saved atrelative physical positions on the distorted image. Firstly, the modedefines in a cache a two-dimensional array with a length at leastcontaining all the dots. Two-dimensional arrays of different lengths areprovided according to different application scenes and different numbersof the black dots on the distorted image. For example in thisembodiment, a two-dimensional array “array[41][41]” with the length of41 is defined. After that, the coordinate value of the center black dotis stored, and during the storing the middlemost position“array[21][21]” is found; the coordinate value of the center black dotis placed into the array “array[21][21]”, the coordinate value of theblack dot on the left and in the same row with the center black dot ofthe distorted image is placed into the “array[20][21]”, and in the samemanner, the coordinate values of other black dots on the distorted imageare placed into the two-dimensional array to establish the indexrelationships between the black dots on the distorted image and thetwo-dimensional array.

FIG. 8 is a reference diagram for calculating a distortion amount of adistorted image provided by an embodiment of the present disclosure.Referring to FIG. 8, after the coordinate values of all the black dotsare obtained, the distorted image is observed to select several key dotsthereon which can best reflect the distortion degrees. Referring to FIG.8, a two-dimensional array in the cache is quickly searched to find fourdots A1, A2, A3 and A4 which can best reflect the calculation of lensdistortion, and the four dots should be close to the edges of thedistorted image as much as possible, i.e., the area defined by the fourdots A1, A2, A3 and A4 can best reflect an area suitable for thecalculation of lens distortion. Every two of the four dots A1, A2, A3and A4 are located in a same reference line outermost and most completeat the edge to define a selected tail end of the reference line, whilesatisfying the following conditions:

Every two of the four dots A1, A2, A3 and A4 are located in a samereference line. The cross dot of the line connecting the dots A1 and A2and the vertical reference line where the center dot is located isdenoted as B1, and the cross dot of the line connecting the dots A2 andA3 and the horizontal reference line where the center dot is located isdenoted as B2. Similarly, dots B3 and B4 are determined. The indexdifferences of the dots A1 and A2 relative to the dot B1 are equal anddenoted as m, the index differences of the dots A3 and A4 relative tothe dot B3 are equal and denoted as n, m=n=9, and the three dots B1, 0(the center black dot) and B3 are located in the same reference line.Similarly, the index differences of the dots A1 and A4 relative to thedot B4 are equal and denoted as u, the index differences of the dots A2and A3 relative to the dot B2 are equal and denoted as v, v=u=9, and thethree dots B2, 0 (the center black dot) and B4 are located in the samereference line. The index difference of 9 indicates that the centerblack dot O is spaced from the dot B1 by 9 black dots. In practice, B1,B2, B3 and B4 may be deemed as the middle dots (or middle dots) of thesame reference lines where every two of the four dots A1, A2, A3 and A4are located, respectively. That is, the center dot of the reference linewhere the dots A1 and A2 are located is B1, the center dot of thereference line where the dots A2 and A3 are located is B2, the centerdot of the reference line where the dots A3 and A4 are located is B3,and the center dot of the reference line where the dots A1 and A4 arelocated is B4.

After the coordinate values of the above key dots A1-A4 and B1-B4 areobtained, calculations will be performed according to the distortionamount calculation formulas:

A distortion amount of the distorted image in a horizontal direction iscalculated according to the following formula:

Horizontal=100%*(DisA1A2+DisA3A4)/(2*DisB2B4)

wherein, DisA1A2 denotes a distance between the dots A1 and A2, DisA3A4denotes a distance between the dots A3 and A4, DisB2B4 denotes adistance between the dots B2 and B4, and Horizontal denotes thedistortion amount of the distorted image in the horizontal direction.

Similarly, a distortion amount of the distorted image in a verticaldirection is calculated according to the following formula:

Vertical=100%*(DisA1A4+DisA2A3)/(2*DisB1B3)

wherein, DisA1A4 denotes a distance between the dots A1 and A4, DisA2A3denotes a distance between the dots A2 and A3, DisB1B3 denotes adistance between the dots B1 and B3, and Vertical denotes the distortionamount of the distorted image in the vertical direction.

The distortion amount of the distorted image can be obtained after thecalculations of the distortion amounts of the distorted image in thehorizontal direction and the vertical direction, thereby obtaining adistortion amount of the lens, and then the distorted image is adjustedto better recover the image and reduce error.

An embodiment of the present disclosure further provides a system formeasuring lens distortion, which applies the method as illustrated inFIG. 1 to measure the lens distortion, and the system comprises:

a test card having a dot matrix pattern of K×N dots;

an imaging device configured to obtain a distorted image of the testcard after being distorted by a lens; and

an image processing device configured to establish a planar coordinatesystem for the distorted image by using a dot at an upper left corner ofthe distorted image as a coordinate origin, a rightward direction fromthe origin as a positive direction of axis X, and a downward directionfrom the origin as a positive direction of axis Y; position a center dotand all non-center dots of the distorted image by scanning andsearching, and determine coordinate values of the center dot and all thenon-center dots in the planar coordinate system; and calculate adistortion amount of the distorted image by using the coordinate valuesof the center dot and all the non-center dots, thereby obtaining adistortion amount of the lens.

In conclusion, the method and system for measuring lens distortion inthe present disclosure defines a new planar coordinate system based onthe distorted image, quickly and accurately finds the dots on the testcard by coordinate positioning, and improves the image processing speedand efficiency. The error range reaches the sub pixel level, and themeasurement accuracy is improved. In addition, the coordinateinformation of the dots on the image is stored in the cache array, whichfacilitates the quick search for the coordinates of the dots on theimage, and the calculation of the distortion amount of the distortedimage, thereby more really reflecting the lens distortion degree.

The above descriptions are just preferred embodiments of the presentdisclosure, rather than limitations to the protection scope of thepresent disclosure. Any amendment, equivalent replacement, improvement,etc. made within the spirit and principle of the present disclosure fallwithin the protection scope of the present disclosure.

1. A method for measuring lens distortion, comprising: providing a testcard having a dot matrix pattern of K×N dots, wherein the K and the Nare both natural numbers, and the K is equal or unequal to the N;obtaining a distorted image of the test card after being distorted by alens; establishing a planar coordinate system for the distorted image byusing a dot at an upper left corner of the distorted image as acoordinate origin, a rightward direction from the origin as a positivedirection of axis X, and a downward direction from the origin as apositive direction of axis Y; positioning a center dot and allnon-center dots of the distorted image by scanning and searching, anddetermining coordinate values of the center dot and all the non-centerdots in the planar coordinate system; and calculating a distortionamount of the distorted image by using the coordinate values of thecenter dot and all the non-center dots, thereby obtaining a distortionamount of the lens; wherein the positioning a center dot of thedistorted image by scanning and searching, and determining coordinatevalues of the center dot in the planar coordinate system comprises:setting a square searching area centered at a coordinate of a center ofthe distorted image, a half of a side length of the square searchingarea being larger than or equal to two times of a radius of the centerdot; setting a square scanning area centered at a dot at an upper leftcorner of the square searching area, a half of whose side length isequal to the radius of the center dot; starting from a center of thescanning area to scan the scanning area, and calculating an averagevalue of all pixel points in the scanning area; in the searching area,sequently moving the center of the scanning area until the searchingarea is completely scanned; comparing the average values of the pixelpoints obtained in the scanning area each time with one another, anddetermining a center of a scanning area where a minimum average value ora maximum average value among all the average values of the pixel pointsis located as a center of the center dot; and determining in turn acoordinate value of the center of the center dot, and determining thecoordinate value of the center of the center dot as the coordinate valueof the center dot.
 2. The method according to claim 1, wherein, on thetest card, the center dot has a radius larger than that of any of thenon-center dots.
 3. (canceled)
 4. The method according to claim 1,wherein the sequently moving the center of the scanning area comprises:in the searching area, moving the center of the scanning area from topto bottom and from left to right until the searching area is completelyscanned; and the positioning all non-center dots of the distorted imageby scanning and searching, and determining coordinate values of all thenon-center dots in the planar coordinate system comprises: moving thesquare searching area leftwards at a specific step length with referenceto the center of the center dot, to position all the non-center dots onthe left and in the same row with the center dot, and determine thecoordinate values of the non-center dots; moving the square searchingarea rightwards at a specific step length with reference to the centerof the center dot, to position all the non-center dots on the right andin the same row with the center dot, and determine the coordinate valuesof the non-center dots; moving the square searching area downwards at aspecific step length with reference to the center of the center dot, toposition all the non-center dots in a row next to the row where thecenter dot is located, and determine the coordinate values of thenon-center dots; and moving the square searching area upwards at aspecific step length with reference to the center of the center dot, toposition all the non-center dots in a row previous to the row wherecenter dot is located, and determine the coordinate values of thenon-center dots.
 5. The method according to claim 4, further comprising:defining in a cache a two-dimensional array with a length at leastcontaining all the dots, and storing coordinate information of thecenter dot into a center array of the two-dimensional array; andsequently storing all the positioned dots into the two-dimensional arrayaccording to relative physical positions on the distorted image, toestablish index relationships of the center dot and all the non-centerdots with the two-dimensional array.
 6. The method according to claim 5,wherein the calculating a distortion amount of the distorted image byusing the coordinate values of the center dot and all the non-centerdots comprises: finding four dots A1, A2, A3 and A4 respectively locatedat an edge of the distorted image according to the index relationshipsof the center dot and all the non-center dots with the two-dimensionalarray, the four dots A1, A2, A3 and A4 simultaneously satisfying acondition that every two of the four dots A1, A2, A3 and A4 are locatedin a same reference line at the edge of the distorted image; findingmiddle dots of the same reference lines where every two of the four dotsA1, A2, A3 and A4 are located, according to index relationships of thecenter dot with the four dots A1, A2, A3 and A4 and all the non-centerdots in the same reference lines where every two of the four dots A1,A2, A3 and A4 are located, wherein an middle dot of the reference linewhere the dots A1 and A2 are located is denoted as B1, a middle dot ofthe reference line where the dots A2 and A3 are located is denoted asB2, a middle dot of the reference line where the dots A3 and A4 arelocated is denoted as B3, and a middle dot of the reference line wherethe dots A1 and A4 are located is denoted as B4, the middle dots B1, B2,B3 and B4 simultaneously satisfying the conditions that, the dot B1, thecenter dot and the dot B3 are located in a same reference line; the dotB2, the center dot and the dot B4 are located in a same reference line;index differences of the dots A1 and A2 relative to the dot B1 are equaland denoted as m, index differences of the dots A3 and A4 relative tothe dot B3 are equal and denoted as n, and m=n; and index differences ofthe dots A1 and A4 relative to the dot B4 are equal and denoted as u,index differences of the dots A2 and A3 relative to the dot B2 are equaland denoted as v, and v=u.
 7. The method according to claim 6, whereinthe calculating a distortion amount of the distorted image by using thecoordinate values of the center dot and all the non-center dots furthercomprises: calculating a distortion amount of the distorted image in avertical direction according to the following formula:Vertical=100%*(DisA1A4+DisA2A3)/(2*DisB1B3) wherein, DisA1A4 denotes adistance between the dots A1 and A4, DisA2A3 denotes a distance betweenthe dots A2 and A3, DisB1B3 denotes a distance between the dots B1 andB3, and Vertical denotes the distortion amount of the distorted image inthe vertical direction; and calculating a distortion amount of thedistorted image in a horizontal direction according to the followingformula:Horizontal=100%*(DisA1A2+DisA3A4)/(2*DisB2B4) wherein, DisA1A2 denotes adistance between the dots A1 and A2, DisA3A4 denotes a distance betweenthe dots A3 and A4, DisB2B4 denotes a distance between the dots B2 andB4, and Horizontal denotes the distortion amount of the distorted imagein the horizontal direction.
 8. The method according to claim 1, whereinthe obtaining a distorted image of the test card after being distortedby a lens comprises: providing an industrial camera, and shooting withthe industrial camera the test card through the lens when a center ofthe industrial camera, a center of the lens, and a center of the testcard coincide, so as to obtain the distorted image.
 9. The method ofclaim 1, wherein, when the center dot and the non-center dots are blackdots, determining the center of the scanning area where the minimumaverage value among all the average values of the pixel points islocated as a center of the center black dot, and determining thecoordinate value of the center of the center black dot.
 10. A system formeasuring lens distortion, wherein the method according to claim 7 isapplied to measure the lens distortion, the system comprising: a testcard having a dot matrix pattern of K×N dots; an imaging deviceconfigured to obtain a distorted image of the test card after beingdistorted by a lens; and an image processing device configured toestablish a planar coordinate system for the distorted image by using adot at an upper left corner of the distorted image as a coordinateorigin, a rightward direction from the origin as a positive direction ofaxis X, and a downward direction from the origin as a positive directionof axis Y; position a center dot and all non-center dots of thedistorted image by scanning and searching, and determine coordinatevalues of the center dot and all the non-center dots in the planarcoordinate system; and calculate a distortion amount of the distortedimage by using the coordinate values of the center dot and all thenon-center dots, thereby obtaining a distortion amount of the lens.